class QueueNode {
    constructor(value) {
        this.item = value;
        this.next = null;
    }   // Create Node
}   // Queue Node

class Queue {
    constructor() {
        this.head = null;
        this.tail = null;
        this.length = 0;
    }   // Initialize Queue

    enqueue(value) {
        let node = new QueueNode(value);

        if (this.tail) {
            this.tail.next = node;
            this.tail = node;
        }   // Append the Node at the End
        else this.head = this.tail = node;

        this.length = this.length + 1;
    }   // Enqueue an Item

    dequeue() {
        let head = this.head;

        if (head) {
            this.head = head.next;
            this.length = this.length - 1;

            if (this.length === 0) {
                this.tail = null;
            }   // Reset Tail

            return head.item;
        }   // Dequeue Item

        return null;
    }   // Dequeue an Item

}   // Trival Queue Implementation

class FastQueue {
    constructor() {
        this.members = [];
    }   // Initialize Queue

    enqueue(value) {
        this.members.push(value);
    }   // Enqueue an Item

    dequeue() {
        return this.members.shift();
    }   // Dequeue an Item

    leng() {
        return this.members.length;
    }   // Return Queue Length

    peekHead() {
        return this.members[0];
    }   // Peek Queue Head

    peekTail() {
        return this.members[this.members.length];
    }   // Peek Queue Tail

}   // Queue Implementation Based on Array
